//这个插件可以实现slide各种情况
;(function($){
    //--------------------- public methods --------------------------
    function pp(info){
       if (window.console && window.console.log)    
            window.console.log('LOG: ' + info ); 
    };
	
	function creat_indicators(obj,opts){	

		obj.append("<ol></ol>");
		
		for(var i = 0;i < obj.find("ul li").length;i++){
			obj.find("ol").append("<li></li>"); 
		};
		
		obj.find("ol").css({
			"left":opts.left,
			'bottom':opts.bottom
		});
	};
	
	function creat_indicators_sum(obj,opts) {
		obj.append("<div></div>");
	}
	
	function callbackSlider(args) {
		obj.find('ol li')
			.removeClass('selected')
			.eq(args.currentSlideNumber - 1)
			.addClass('selected');		
    };

	function creat_indicators(obj,opts){
	
		obj.append("<ol></ol>");
		var oList = obj.find('ol');

		for(var i = 0; i < obj.find("ul li").length; i++){

			oList.append("<li></li>"); 

		};
		
		oList.css({"left":opts.left,'bottom':opts.bottom});

	};
	
	
	function callbackSliderChanged(args) {

	    obj.find('ol li').removeClass('selected');
	    obj.find('ol li:eq(' + (args.currentSlideNumber - 1) + ')').addClass('selected');
		
    };

    function callbackSliderLoadedChanged(obj,args) {

	    obj.find('ol li').removeClass('selected');
	    obj.find('ol li:eq(' + (args.currentSlideNumber - 1) + ')').addClass('selected');		
    };	
	
	// function creat_indicators_sum(obj,opts,args) {
		// obj.append("<div></div>");
		// obj.find('div').html((args.currentSlideNumber-1)+'/'+obj.find("ul li").length)
		
	// }
	
	
	function ios_slide(obj,opts){

		obj.iosSlider({

	        desktopClickDrag: opts.desktopClickDrag, 
	        snapToChildren: opts.snapToChildren,
	        infiniteSlider: opts.infiniteSlider,
	        onSliderLoaded: function(args){
				callbackSlider(args);
				opts.onSlider(args);
				creat_indicators_sum(obj,opts,args)
			},
	        onSlideChange: function(args){
				callbackSlider(args);
				opts.onSlider(args);
				creat_indicators_sum(obj,opts,args)
			},
			autoSlide: opts.autoSlide,
			autoSlideTimer: opts.autoSlideTimer,
			sliderIndicators:opts.sliderIndicators
			

        });
	};
	//----------------------- jquery   plugin  -----------------------
    $.fn.lt_slide = function(options) { 
	    // 将defaults 和 options 参数合并到{}   
		var opts = $.extend({}, $.fn.lt_slide.defaults, options);  
			
	    return this.each(function() { 

			obj = $(this);
			
			if(opts.sliderIndicators == 1){
				//让slide滑动	
				ios_slide(obj,opts);
				
				return
			}else if(opts.sliderIndicators == 2){
				//创建creat_indicators	
				creat_indicators(obj,opts);	
				//让slide滑动	
				ios_slide(obj,opts);
			}//else if(opts.sliderIndicators == 3) {
				//创建creat_indicators	
				// creat_indicators_sum(obj,opts);
				//让slide滑动	
				// ios_slide(obj,opts);
			// }	
        });
    }; 
	 //默认值   
	$.fn.lt_slide.defaults = {
	    desktopClickDrag: true, //触摸滑动
	    snapToChildren: true, //滑动的流畅
		infiniteSlider: true, //滑到最后是否重新开始
		sliderIndicators:2, //图片上是否需要indicators
		onSlider:function(){			
		}, //在每张图片之后是否需要调用一些数据
		autoSlide: false,//图片是否需要自动滚动
		left:'15px', //indicators的位置
		bottom:'15px'
	};
})(jQuery);